<?php
	require('../Model/mysql.php');
	require('../host_config.php');
  require_once('forPhoneController.php');
	$mysql = new MySQL();
  $qryWaiting = new forPhoneController();
    $link = $mysql->connect($mysql_host, $mysql_user, $mysql_passwd, $mysql_db);
    if (isset($_POST["shopid"]) && isset($_POST["orderofnum"])) {
    	$shopid = $mysql->real($_POST["shopid"]);
    	$orderofnum = $mysql->real($_POST["orderofnum"]);
    	/*$ShopName = $_POST[" ShopName"];
  		$ShopName = mysql_real_escape_string($ShopName);
  		$PeoNumber = $_POST["PeoNumber"];
  		$PeoNumber = mysql_real_escape_string($PeoNumber);*/

  		//$sql  = "select max_number, current from android where `all_name` = '$ShopName'";
    	$sql  = "select maxofnumber, currentnumber from Shops where `shopid` = '$shopid'";
  		//$result = mysql_query($sql, $link) or die("Execute SQL command failed!");
  		//$row = mysql_fetch_row($result);
  		$row = $mysql->query_row($sql, $link);
  		$maxofnumber = $row[0];
  		$currentnumber = $row[1];

  		//if($max_number - $current >= $PeoNumber)
  		if($maxofnumber - $currentnumber >= $orderofnum)
  		{
  			print_r("OK!!");
  		}else {
        print_r($qryWaiting->qryWaitingTime($mysql, $link, $shopid, $orderofnum));
  		}

    }else {
    	print_r("error");
  	}

